<template>
  <div class="login-container">
    <!-- 背景层 -->
    <div class="background-image"></div>
    
    <!-- 登录表单层 -->
    <div class="login-form">
      <div class="avatar-container">
        <img src="../../assets/login/person.png" alt="用户头像" class="avatar">
        <div class="username">admin</div>
      </div>
      
      <div class="input-container">
        <input 
          v-model="pin" 
          type="password" 
          placeholder="请输入PIN码" 
          @keyup.enter="handleLogin"
          class="pin-input"
        >
      </div>
      
      <div class="forgot-pin" @click="showForgotDialog">
        我忘记了PIN码
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const pin = ref('')
const router = useRouter()

const handleLogin = () => {
  if (pin.value === 'admin') {
    router.push('/home') // 跳转到仪表盘路由
  } else {
    alert('PIN码错误，请重试')
    pin.value = ''
  }
}

const showForgotDialog = () => {
  alert('请联系系统管理员重置PIN码')
}
</script>

<style lang="scss" scoped>
.login-container {
  position: relative;
  height: 100vh;
  overflow: hidden;

  .background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: {
      image: url('../../assets/login/bg.jpg');
      size: cover;
      position: center;
    }
    filter: blur(8px);
    z-index: 1;
    
    &::after {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.3);
    }
  }

  .login-form {
    position: absolute;
    top: 50%;
    left: 50%;  
    transform: translate(-50%, -50%);
    width: 320px;
    // background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    // border-radius: 16px;
    padding: 40px 30px;
    // box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 2;

    .avatar-container {
      margin-bottom: 30px;
      
      .avatar {
        width: 90px;
        height: 90px;
        border-radius: 50%;
        object-fit: cover;
        border: 3px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        background-color: #fff;
      }
      
      .username {
        margin-top: 12px;
        color: #fff;
        font-size: 18px;
        font-weight: 500;
       
      }
    }

    .input-container {
      margin-bottom: 20px;
      
      .pin-input {
        width: 100%;
        padding: 12px 16px;
        border: none;
        border-radius: 8px;
         background-color: #1c1c1c;
         opacity: .7;
        font-size: 16px;
        outline: none;
        transition: all 0.3s;
        
        // &:focus {
        //   background-color: #fff;
        //   box-shadow: 0 0 0 2px rgba(66, 185, 131, 0.5);
        // }
        
        &::placeholder {
          color: #fff;
        }
      }
    }

    .forgot-pin {
      color: rgba(255, 255, 255, 0.7);
      font-size: 14px;
      cursor: pointer;
      transition: color 0.2s;
      
      &:hover {
        color: #fff;
        text-decoration: underline;
      }
    }
  }

  @media (max-width: 768px) {
    .login-form {
      width: 85%;
      padding: 30px 20px;
      
      .avatar {
        width: 70px;
        height: 70px;
      }
    }
  }
}
</style>